package singleton.type8;

/**
 * @author 龙超
 * @date 2020/7/1 16:43
 * @Description
 */
public class Singleton8 {
    public static void main(String[] args) {
        Singleton instance = Singleton.INSTANCE;
        Singleton instance1 = Singleton.INSTANCE;
        System.out.println(instance == instance1);//true
        System.out.println(instance.hashCode());
        System.out.println(instance1.hashCode());

    }
}

//使用枚举
enum Singleton {
    INSTANCE;//属性

    public void sayOK() {
        System.out.println("ok----");
    }

}
